package light.head.config;


import java.util.Iterator;

import light.head.cache.BCache;
import light.head.constant.Parm;
import light.head.framework.utils.XmlUtils;

import org.dom4j.Document;
import org.dom4j.Element;


/**
 * 单据业务类型配置文件读取
 * @author yangguanghe @date 2014-7-2 @time 下午5:22:39
 *
 */
public class BillBusinessTypeParm {

	private final static String path = "/config/billBusinessType.xml";
	
	@SuppressWarnings("unchecked")
	public static boolean loadBillBusinessType() {
		
		Document xml = XmlUtils.loadXML(path);
		Element element = xml.getRootElement();
		
		if (null != element && element.elements().size() > 0) {
			
			for (Iterator<Element> eList = element.elementIterator(); eList.hasNext();) {
				Element bill = eList.next();
				if (null == bill)
					continue;
				
				BCache.bTypes.put(bill.attributeValue(Parm.CODE), bill.attributeValue(Parm.NAME));
			}
			return true;
		}
		return false;
	}
	
}
